package com.gzyj.jtt808.v2013.model.position.additionalInfo;


import com.gzyj.jtt808.utils.HexBytesUtil;
import com.gzyj.jtt808.v2011.additionalinfo.JTT808_AddtionalInfo;
import io.netty.buffer.ByteBuf;
import lombok.Data;

import java.io.Serializable;

/**
 * 模拟量
 * @author lhj
 */
@Data
public class JTT808_0x0200_0x2B extends JTT808_AddtionalInfo implements Serializable {
    private Integer Analog;
    public JTT808_0x0200_0x2B(){
        this.setID(0x2B);
        this.setLength(4);
    }

    @Override
    public void encode(ByteBuf buf) {
        buf.writeByte(this.getID());
        buf.writeByte(this.getLength());
        buf.writeInt(this.Analog);
    }

    @Override
    public JTT808_0x0200_0x2B decode(ByteBuf buf) {
        byte[] temp= HexBytesUtil.readByOffset(buf,1);
        this.setLength(Integer.parseInt(HexBytesUtil.bytesToHex(temp),16));
        this.Analog=buf.readInt();
        return this;
    }

}
